package com.lengchangjing.ConstructionalPatterns.PrototypePattern;

import java.io.IOException;
import java.io.OptionalDataException;

public class DeepCloneClient {
    public static void main(String[] args) {
        ClassA classA = new ClassA("name", 50);
        ConcretePrototypeB prototypeB = new ConcretePrototypeB();
        prototypeB.setField1("some");
        prototypeB.setField2(24);
        prototypeB.setClassA(classA);

        try {
            ConcretePrototypeB brother = prototypeB.deepClone();
            System.out.println(brother == prototypeB);  // false
            System.out.println(brother.getClassA() == prototypeB.getClassA());  // false

        } catch (OptionalDataException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
